package com.xebest.config;

import com.xebest.web.service.SendGoodOrderChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * 发货通知发送类
 *
 * @author 李贝贝
 */
@Component
@EnableBinding(SendGoodOrderChannel.class)
public class SendGoodOrderSender {
    private static final Logger log = LoggerFactory.getLogger(SendGoodOrderSender.class);// 日志记录类
    public static SendGoodOrderSender sender = null;

    @PostConstruct
    public void init() {
        sender = this;
    }

    @Resource
    private SendGoodOrderChannel sendGoodOrderChannel;

    public void sendMessage(String sendJson) {
        try {
            sendGoodOrderChannel.output().send(MessageBuilder.withPayload(sendJson).build());
        } catch (Exception e) {
            log.error("发货通知发送异常：{}", e);
        }
    }
}
  
